﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using System.Web.Security;
using System.Web;

namespace JinianNet.JNCms.Controllers
{
    public class AccountController : Controller
    {
        public ActionResult Login(JinianNet.JNCms.Models.Users account)
        {
            FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, account.UserName, DateTime.Now, DateTime.Now.AddDays(1), false, "admin");
            base.ControllerContext.HttpContext.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket)));
            return View();
        }

        public ActionResult Logout(string url)
        {
            FormsAuthentication.SignOut();
            if (!string.IsNullOrEmpty(url))
                return Redirect(url);
            return View();
        }
    }
}
